package com.springboot.myspringbootframework.web.controller;

import com.springboot.myspringbootframework.domain.user.api.UserApi;
import com.springboot.myspringbootframework.domain.user.api.dto.UserDTO;
import com.springboot.myspringbootframework.domain.user.entities.User;
import com.springboot.myspringbootframework.domain.user.service.UserService;
import com.springboot.myspringbootframework.web.exception.MyException;
import com.springboot.myspringbootframework.web.mq.provider.Provider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @Autowired
    private UserApi userService;
    @Autowired
    private Provider provider;

    @GetMapping("/demo")
    public String demo(){
        return "demo";
    }
    @GetMapping("/demo/mybatis/{id}")
    public UserDTO getUser(@PathVariable("id") Integer uid){
        UserDTO user = userService.getDemo(uid);
        return user;
    }

    @GetMapping("/demo/exception")
    public String demo2(){
        throw new MyException("errorrrrrr");
    }
    @GetMapping("/myRabbit")
    public String demo3(){
        provider.send();
        return "";
    }
}
